<!-- 业务详情 -->
<template>
  <uni-list :border="false">
    <uni-list-item title="业务当前进度" :rightText="detailsData.xmjl" />
  </uni-list>
  <uni-section title="基本信息" type="line" />
  <uni-list :border="false">
    <uni-list-item title="业务编号" :rightText="detailsData.ywbh + ''" />
    <uni-list-item title="业务类别" :rightText="getywlbText(detailsData.ywlb)" />
    <uni-list-item title="申请时间" :rightText="detailsData.sqrq + ''" />
    <uni-list-item title="申请人" :rightText="detailsData.lxr + ''" />
    <uni-list-item title="联系电话" :rightText="detailsData.lxsj + ''" />
    <uni-list-item title="用电地址" :rightText="detailsData.yhdz + ''" />
  </uni-list>
  <!-- <view class="p20">
    <button type="warn" @click="cancelClick">取消业务办理</button>
  </view> -->
</template>


<script setup lang="ts">
  import { YhYwJbxx } from "@/api/tables/YhYwJbxx";
  import { businessCancel } from "@/api/request/businessCancel"
  import { SysZfdmQuery } from "@/api/request/SysZfdmQuery";
  import { SysZfdm } from "@/api/tables/SysZfdm"
  import { ref } from "vue"
  import { onLoad } from '@dcloudio/uni-app'

  let detailsData = ref<YhYwJbxx>({})
  const YWLBLIST = ref<Array<SysZfdm>>([])
  onLoad((option) => {
    let data = option.detailsData || ''
    detailsData.value = JSON.parse(data)
    SysZfdmQuery({
      data: { zfdm: { dmzl: "YWLB" } },
      success: (result) => {
        let list = result || []
        YWLBLIST.value = list
      }
    })
    // getSysZfdm({
    // 	dmzl: "YWLB",
    // 	success: (result) => {
    // 		YWLBLIST.value = result
    // 	}
    // })
  });
  const getywlbText = (ywlb : String) => {
    for (let k of YWLBLIST.value) {
      if (k.dmbh == ywlb) {
        return k.dmnr
      }
    }
    return ''
  }

  function cancelClick() {
    uni.showModal({
      title: '提示',
      content: '是否确定取消',
      success: function (res) {
        if (res.confirm) {
          businessCancel({
            data: {
              jbxx: detailsData.value
            },
            success: () => {
              uni.showToast({ icon: "success", title: '取消成功' })
              uni.navigateBack()
            },
            fail: (_code, message) => {
              uni.showModal({ content: "业务取消失败，请稍后重试", showCancel: false })
            }
          })
        }
      }
    });
  }
</script>

<style lang="scss">

</style>